package cz.techi;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class PreviewActivity extends Activity {
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.preview);
        
        
        
        

        ScheduleDb sd = new ScheduleDb(this);
        Subject[] subjects = sd.getSubjects();
        sd.close();
        
        
        if (subjects.length == 0)
        {
        	Intent myIntent = new Intent(this, LoadActivity.class);
            startActivityForResult(myIntent, 0);
        }

        Schedule schedule = Schedule.getInstance();
        schedule.setSubjects(subjects);
        
        
        
        
        
        Subject s = schedule.getNextSubject();
        
        if (s != null)
        {

        	TextView text = (TextView)this.findViewById(R.id.info);
        	text.setText("Next subject: " + s.ident + "\n" + s.getLocalizedDay() + " " + s.from + "-" + s.to + "\n" + s.name + "\n" + s.room + "\n" + s.type + " " + s.teacher);
        }
        
        
        
        
        //sd.close();
 }
	

	@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu, menu);
        return true;
    }
	
	  @Override
	    public boolean onOptionsItemSelected(MenuItem item) {
	        // Handle item selection
	    	
	    	return MenuHandler.handle(this, item);
	  }
}
